import $app from '../$app';


// 专用
export default {
	// 配合上面使用，备注有点多，有点啰嗦
	gonRi(that, resData) {

		that.business_license_path = resData.pdf;//文件地址赋值
		that.business_license_img_path = resData.jpg;//文件地址赋值

		if ($app.judgeData(resData.yyzz)) {

			let jutt = true;

			////申请人类型 1企业 2个体工商户
			if (that.reg_people_type == 1) {//1企业
				
				//重新初始化
				that.reg_people_name = '';
				that.business_license_number = '';
				that.initFirstData_address();//清空地址
				
				if ($app.judgeData(resData.yyzz.company_name)) {
					that.reg_people_name = resData.yyzz.company_name;
				} else {
					jutt = false;
					$app.alert('公司名称识别失败，请手动填写资料提交', '温馨提示', () => {
						that.$refs['reg_people_name'].focus();
					});
					return
				}

				if ($app.judgeData(resData.yyzz.register_num)) {
					that.business_license_number = resData.yyzz.register_num;
				} else {
					jutt == false;
					$app.alert('证件号码识别失败，请手动填写资料提交', '温馨提示', () => {
						that.$refs['business_license_number'].focus();
					});
					return
				}

				if ($app.judgeData(resData.yyzz.address_detail)) {
					this.address_set_all(that,resData.yyzz)
				} else {
					jutt = false;
					$app.alert('详细地址识别失败，请手动填写资料提交', '温馨提示', () => {
						that.$refs['business_license_detail_address'].focus();
					});
					return
				}

			} else {//2个体工商户

				//重新初始化
				that.business_license_number = '';


				if ($app.judgeData(resData.yyzz.register_num)) {
					that.business_license_number = resData.yyzz.register_num;
				} else {
					jutt == false;
					$app.alert('证件号码识别失败，请手动填写资料提交', '温馨提示', () => {
						that.$refs['business_license_number'].focus();
					});
					return
				}
			}

			if (!!jutt) {
				$app.alertGood('信息识别成功，请核对信息是否有误。', 'AI智能识别 ');
			}

		} else {
			$app.alert('营业执照识别失败，请手动填写资料提交', '温馨提示', () => {
				that.$refs['business_license_number'].focus();
			});
		}

	},

	//配合上者使用 ，备注太多，不做介绍 
	rMpW(that, resData) {
		that.initFirstData_address();//清空地址
		that.idcard_path = resData.pdf;
		that.idcard_img_path = resData.jpg;

		
		if ($app.judgeData(resData.idcard)) {
			let jutt = true;

			//重新初始化
			that.reg_people_name = '';
			that.idcard = '';
			that.initFirstData_address();//清空地址



			if ($app.judgeData(resData.idcard.name)) {
				that.reg_people_name = resData.idcard.name;
			} else {
				jutt = false;
				$app.alert('申请人名称识别失败，请手动填写资料提交', '温馨提示', () => {
					that.$refs['reg_people_name'].focus();
				});
				return
			}

			if ($app.judgeData(resData.idcard.id)) {
				that.idcard = resData.idcard.id;
			} else {
				jutt = false;
				$app.alert('证件号码识别失败，请手动填写资料提交', '温馨提示', () => {
					that.$refs['idcard'].focus();
				});
				return
			}

			if ($app.judgeData(resData.idcard.address_detail)) {
				this.address_set_all(that,resData.idcard)
			} else {
				jutt = false;
				$app.alert('申请人地址识别失败，请手动填写资料提交', '温馨提示', () => {
					that.$refs['business_license_detail_address'].focus();
				});
				return
			}

			if (!!jutt) {
				$app.alertGood('信息识别成功，请核对信息是否有误。', 'AI智能识别 ');
			}

		} else {
			$app.alert('身份证识别失败，请手动填写资料提交', '温馨提示', () => {
				that.$refs['idcard'].focus();
			});
		}


		
	},

	address_set_all(that,obj){
		// console.log('真的来到这 = ',obj)

		
		that.business_license_detail_address=obj.address_detail;//地址(短地址)

		if(!obj.province || !obj.province_code){
			if(!obj.province){
				$app.alert('省份识别失败，请手动选择省份');
			}else{
				$app.alert('省份代码识别失败，请手动选择省份');
			}
		}else if(!obj.city || !obj.city_code){
			if(!obj.city){
				$app.alert('市区识别失败，请手动选择市区');
			}else{
				$app.alert('市区代码识别失败，请手动选择市区');
			}
		}else{//4个全都有进来这里
			that.business_license_province=obj.province;//省份名称 中文汉字
			that.business_license_province_code=obj.province_code;//省份代码
			that.business_license_city=obj.city;//城市名称 中文汉字
			that.business_license_city_code=obj.city_code;//城市代码

			//执行一般城市列表 赋值，演示执行更优秀
			setTimeout(()=>{
				that.business_license_province_code_Fun();	
			},105);
		}

		
		
	}
	
};
